package com.techstar.ats.codec.history.decoder;

import io.netty.buffer.ByteBuf;
import com.techstar.ats.codec.Decoder;
import com.techstar.ats.codec.StringCodec;
import com.techstar.ats.dxp.history.F22InusedRecord;
import com.techstar.ats.dxp.history.F22InusedTrip;

public enum F22InusedTripDecoder implements Decoder<F22InusedTrip> {
	INSTANCE;

	public F22InusedTrip create() {
		return new F22InusedTrip();
	}

	public void decode(ByteBuf buf, F22InusedTrip value) {
		value.global = (new StringCodec(12)).get(buf);
		value.group = (new StringCodec(9)).get(buf);
		value.dest = (new StringCodec(4)).get(buf);
		int cnt = buf.readUnsignedShort();

		for(int i = 0; i < cnt; ++i) {
			F22InusedRecord record = F22InusedRecordDecoder.INSTANCE.create();
			F22InusedRecordDecoder.INSTANCE.decode(buf, record);
			value.records.add(record);
		}

	}
}
